package com.rbac.web.model.res;

import com.rbac.web.model.User;
import io.swagger.v3.oas.annotations.media.Schema;
import java.time.LocalDateTime;
import java.util.List;import lombok.Builder;
import lombok.Data;

/**
 * @author gengaoliu
 */
@Data
@Builder
@Schema(description = "账号详情返回参数")
public class UserGetOneRes {
  @Schema(description = "id")
  private Integer id;

  @Schema(description = "创建时间")
  private LocalDateTime createdTime;

  @Schema(description = "姓名")
  private String name;

  @Schema(description = "电话")
  private String phone;

  @Schema(description = "账号")
  private String username;

  @Schema(description = "密码")
  private String password;

  @Schema(description = "账号状态")
  private Boolean status;

  @Schema(description = "角色ID")
  private List<Integer> roleId;

  @Schema(description = "角色名称")
  private List<String> roles;

  public static UserGetOneRes from(User domain) {
    return UserGetOneRes.builder()
        .id(domain.getId())
        .createdTime(domain.getCreatedTime())
        .name(domain.getName())
        .phone(domain.getPhone())
        .username(domain.getUsername())
        .password(domain.getPassword())
        .roleId(domain.getRoleId())
        .build();
  }
}
